/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package validation;
import java.util.regex.Pattern;
import java.util.regex.Matcher;
/**
 *
 * @author Jhon
 */
public class Validation {
    private static Validation INSTANCE = null;
    private Validation() {}
    private synchronized static void createInstance() {
        if (INSTANCE == null) {
            INSTANCE = new Validation();
        }
    }
  public static Validation getInstance() {
        if (INSTANCE == null) createInstance();
        return INSTANCE;
    }
  private Pattern p;
  private Matcher m;
  public boolean length30(String x){
      if(x.length()>30)return false;
      else return true;
  }

  public boolean isInteger(String x){
       p = Pattern.compile("[0-9]");
         m = p.matcher(x);
        return m.matches();
  }

  public boolean isEmail(String x){
         p = Pattern.compile("[a-zA-Z0-9]+[.[a-zA-Z0-9_-]+]*@[a-z0-9][\\w\\.-]*[a-z0-9]\\.[a-z][a-z\\.]*[a-z]$");
         m = p.matcher(x);
        return m.matches();
  }

  public boolean isChar(String x){
       p = Pattern.compile("[^0-9]");
        m = p.matcher(x);
        return m.matches();
  }

  public boolean isNotNull(String[] x){
      for(String f : x){
          if(f==null || f.isEmpty() || f.equals(""))
              return false;
          }
      return true;
  }

  public boolean passwd(String x){
      p = Pattern.compile("[a-zA-Z0-9_-]");
         m = p.matcher(x);
        return m.matches();
  }

}
